@extends('admin.common.main')
@section('css')
    <!--引入CSS-->
    <link rel="stylesheet" type="text/css" href="/webuploader/webuploader.css">
@endsection
@section('content')
    <body>
    <article class="page-container">
        <form action="{{route('admin.fang_attr.store')}}" method="post" class="form form-horizontal"
              id="form-member-add">
            @include('admin.common.error')

            @csrf
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>房源属性名称：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="" placeholder="" id="name" name="name">
                </div>
            </div>

            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>字段名：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="" placeholder="" id="field_name" name="field_name">
                </div>
            </div>

            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>图标：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <div id="picker">选择文件

                    </div>
                    <img src="" id="img" alt="" width="100" height="100" hidden>
                    <input type="hidden" value="" name="icon" id="pic">
                </div>
            </div>

            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>是否是顶级：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <select name="pid" id="" class="select-box">
                        <option value="0">===顶级===</option>
                        @foreach($data as $val)
                            <option value="{{$val['id']}}">{{$val['html']}}{{$val['name']}}</option>
                        @endforeach
                    </select>
                </div>
            </div>

            <div class="row cl">
                <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                    <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
                    <a href="javascript:;" onclick="history.go(-1)" class="c-primary btn btn-dark radius">&lt; 返回上一页</a>
                </div>
            </div>
        </form>
    </article>
    @endsection

    @section('js')
        <script type="text/javascript" src="/ueditor/ueditor.config.js"></script>
        <!-- 编辑器源码文件 -->
        <script type="text/javascript" src="/ueditor/ueditor.all.js"></script>

        <script type="text/javascript" src="/webuploader/webuploader.js"></script>
        <!-- 实例化编辑器 -->
        <script type="text/javascript">
            var ue = UE.getEditor('body');

            var uploader = WebUploader.create({

                // swf文件路径
                swf: '/webuploader/Uploader.swf',
                method: 'post',
                auto: true,
                chunked: true,//是否要分片处理大文件上传。
                chunkSize:1048576,//分5M片
                chunkRetry:2,//某个分片由于网络问题出错，允许自动重传2次
                threads:3,//上传并发数。允许同时最大上传进程数。
                formData: {
                    _token: "{{csrf_token()}}"
                },
                server: "{{route('admin.fang_attr.oss_upfile')}}",


                pick: '#picker',

                resize: false,
            });

            uploader.on('uploadSuccess', function (pic, ret) {
                $('#img').show().attr('src', ret.data.icon);
                $('#pic').val(ret.data.icon);
            });

        </script>
@endsection
